﻿using System.Collections.Generic;
using System.Web.Http;
using MaciejGrabek.WP7.Services.Model.Entities;
using MaciejGrabek.WP7.Services.Model.Repositories;

namespace MaciejGrabek.WP7.Services.Controllers
{
    public class GameResultsController : ApiController
    {
        // GET /api/gameResults/gameNormalizedName
        public IEnumerable<GameResultLightDto> Get(string gameNormalizedName)
        {
            GameResultsRepository repository = new GameResultsRepository();
            return repository.GetGameResults(gameNormalizedName);
        }

        // POST /api/gameResults
        /* Sample request body
            {
                "GameHash" : "E47552CF-AF1F-4cb6-BA2E-3F7289F98233",
                "Score" : "202",
                "PlayerName": "Maciej Grabek",
                "DeviceId" : "someDevideId"
            }
         */
        public void Post(GameResultDto value)
        {
            GameResultsRepository repository = new GameResultsRepository();
            repository.SetGameResult(value);
        }
    }
}